import win32api
import time
from bdtime import tt


class MouseTracker:
    def __init__(self, frames=60):
        self.frames = frames

    def track_mouse_movement(self, until_key='esc'):
        mouse_trajectory = []

        while not tt.is_pressed(until_key):
            # print(tt.is_pressed('s'))
            x, y = win32api.GetCursorPos()
            mouse_trajectory.append((x, y))
            time.sleep(1/self.frames)

        return mouse_trajectory


# 示例用法
tracker = MouseTracker()

trajectory = tracker.track_mouse_movement()
print('len:', len(trajectory), '---', trajectory[:10])

